$(function() {
	$("#left").load("../common/gover-left.html");
	var userId = sessionStorage.getItem("userId");
	var Imgs = sessionStorage.getItem("ImgItems");
	var apId = parseQueryString().applyId;
	var fromSpace = isEmpty(parseQueryString().fromSpace) ? '0' : parseQueryString().fromSpace;
	$(".ystep1").loadStep({
		size: "small",
		color: "green",
		steps: [{
				title: "事项选择"
			},
			{
				title: "服务选择"
			},
			{
				title: "信息录入"
			},
			{
				title: "寄件选择"
			},
			{
				title: "取件选择"
			},
			{
				title: "提交成功"
			}
		]
	});
	$(".ystep1").setStep(3);
	my_vue = new Vue({
		el: '#vue_info',
		data: {
			titleName:sessionStorage.getItem('titleName'),
			dto: {
				regNumber: "",
				regAddress: "",
				companyName: "",
				regDate: "",
				regCapital: "",
				companyTel: "",
				applyId: "",
				cardNum: "",
				contactName: "",
				mobile: "",
				userType: "",
				name: ""
			},
			itemsList: [],
			ImgItems: toObj(Imgs)
		},
		methods: {
			nextStep: function() {
				this.$http.post(gover.submitFiles, {
					userId: userId,
					fromSpace: fromSpace
				}, {
					emulateJSON: true
				}).then(function(result) {
					console.log(toJson(result.data));
					if(result.data.success) {
						sessionStorage.removeItem('ImgItems');
						if(fromSpace == '1') {
							window.location = "../space/index.html";
						} else {
							window.location = "selfHelpChooseCommitType.html"
						}

					} else {
						console.log(result.data.message);
					}

				}, function() {
					console.log('保存接口失败:' + toJson(result));
					top.$.closePopWin();

				})
			},
			toPhoto: function() {
				if(this.itemsList<=0){
					window.location="selfHelpFormInput.html?applyId="+apId;
				}else{
					history.go(-1);
				}
			},
			exitAttendTo: function() {
				$.openDialog({
					'title': '',
					"showClose": false,
					'width': 824,
					'height': 460,
					'url': 'selfHelpExitChoose.html'
				});
			},
			getApplyInfo: function() {
				var appId = '';
				if(fromSpace=='1') {
					appId = apId;
				}
				this.$http.get(gover.getApplyInfo+"?t="+new Date().getTime(), {
					userId: userId,
					applyId: appId
				}).then(function(result) {
					doMask();
					if(result.data.success) {
						console.log(toJson(result.data.data));
						this.dto = result.data.data;
						this.getCailiaos();
					}else{
						unMask();
						showRedMsg("message", "服务器正忙,请稍候重试");
					}
					console.log(toJson(result.data));
				}, function() {
					unMask();
					showRedMsg("message", "服务器正忙,请稍候重试");
					console.log('保存接口失败:' + toJson(result));
				})
			},
			getCailiaos: function() {
				this.$http.get(gover.getCailiaos, {
					applyId: this.dto.applyId
				}).then(function(result) {
					console.log(toJson(result.data));
					if(result.data.success) {
						unMask();
						this.itemsList = result.data.data;
					} else {
						unMask();
						showRedMsg("message", "服务器正忙,请稍候重试");
						console.log(result.data.message);
					}

				}, function() {
					unMask();
					showRedMsg("message", "服务器正忙,请稍候重试");
					console.log('保存接口失败:' + toJson(result));

				})
			}

		},

		ready: function() {
			//初始化获得总页面数和列表数据
			this.getApplyInfo();
		}
	});
});